package com.example.myapplication.ui.adapter;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

/**
 * Created by meishiyiyun on 2017/5/19.
 */

public class BaseGuidAdapter extends PagerAdapter {
    int [] str;
    public BaseGuidAdapter(int[] strs) {
        this.str=strs;
    }

    @Override
    public int getCount() {
        return str.length;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view ==object;
    }

    @Override
        public Object instantiateItem(ViewGroup container, int position) {
            // 将图片添加到ViewPager容器
         ImageView imageView=   new ImageView(container.getContext());
            imageView.setBackgroundResource(str[position]);
            container.addView(imageView);
            return str[position];
        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
            container.removeView((View) object);
        }
}
